package Test1;


class Teacher{
    static Object object = new Object();
     public static void EnglishClass(){
        //t2等待区

                System.out.println("ABCDEFG...."+ ThreadDemo14.size);
                ThreadDemo14.size--;
            }
}
class ThreadDemo14 {
    public static int size = 50;
    static Object object = new Object();
    public static void main(String[] args) {


            Thread A = new Thread(()->{
                while (size > 1)
                    synchronized (object) {

                        Teacher.EnglishClass();
                    }
            }) ;
            Thread B = new Thread(()->{
                while (size > 1) {

                    synchronized (object) {

                        Teacher.EnglishClass();
                    }
                }
            }) ;

            A.start();
            B.start();
    }
}
